import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      // component: HomeView
      redirect: '/componentView' // 重定向
    },
    {
      path: '/componentView',
      name: 'componentView',
      component: () => import('@/views/ComponentView/index.vue'),
      children: [], // 子路由
      meta: {} // 路由元信息
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/user',
      name: 'User',
      component: () => import('../views/user/index.vue'),
      meta: {
        keepAlive: true
      }
    },
    {
      path: '/role',
      name: 'role',
      component: () => import('../views/role/index.vue')
    }
  ]
})

export default router
